﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class gaInfo_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        int id = int.Parse(Request["id"].ToString());
        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        gaInfoNews.News news = new gaInfoNews().GetNewsById(id);
        txtNum.Text = news.N_id.ToString();
        txtTitle.Text = news.N_title;
        txtContent.Text = news.N_content;
    }
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request["id"].ToString());
        gaInfoNews.News news = new gaInfoNews().GetNewsById(id);
        news.N_id =int.Parse(txtNum.Text);
        news.N_title = txtTitle.Text;
        news.N_content = txtContent.Text;
        news.N_cTime = news.N_cTime;
        bool update = new gaInfoNews().UpdateNewsById(news);
        if (update)
        {
            ClientScript.RegisterStartupScript(GetType(), "update", "alert('修改成功');document.location='Default.aspx'", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "updatefail", "alert('修改失败')", true);
        }
    }
}